package cn.swu.Waimai.ui.activity

import android.annotation.SuppressLint
import android.content.ContentValues
import android.os.Bundle
import cn.swu.Waimai.R
import cn.swu.Waimai.logic.dao.LoginHelper
import kotlinx.android.synthetic.main.activity_login_password.*
import kotlinx.android.synthetic.main.activity_register.*
import kotlinx.android.synthetic.main.activity_register.entered_password
import kotlinx.android.synthetic.main.activity_register.entered_phone

class RegisterActivity: BaseActivity() {
    @SuppressLint("CommitPrefEdits")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_register)

        register_back.setOnClickListener{
            onBackPressed()
        }

        val phone = entered_phone.text.toString()
        val password = entered_password.text.toString()
        register.setOnClickListener{
            val dbHelper = LoginHelper(this,"USERLOGIN.db",2)
            dbHelper.writableDatabase
            val db = dbHelper.writableDatabase
            val values = ContentValues().apply{
                put("phone",phone)
                put("password",password)
            }
            db.insert("Login",null,values)
            onBackPressed()
        }
    }
}